<!--********************************************************************
* Copyright© 2000 - 2018 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title data-i18n="resources.title_mapVLayerPolygon"></title>
    <style>
        .ol-popup {
            position: absolute;
            background-color: white;
            -webkit-filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
            filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
            padding: 15px;
            border-radius: 10px;
            border: 1px solid #cccccc;
            bottom: 12px;
            left: -50px;
            min-width: 280px;
            font-size: 8pt;
        }

        .ol-popup:after, .ol-popup:before {
            top: 100%;
            border: solid transparent;
            content: " ";
            height: 0;
            width: 0;
            position: absolute;
            pointer-events: none;
        }

        .ol-popup:after {
            border-top-color: white;
            border-width: 10px;
            left: 48px;
            margin-left: -10px;
        }

        .ol-popup:before {
            border-top-color: #cccccc;
            border-width: 11px;
            left: 48px;
            margin-left: -11px;
        }

        .ol-popup-closer {
            text-decoration: none;
            position: absolute;
            top: 2px;
            right: 8px;
        }

        .ol-popup-closer:after {
            content: "✖";
        }
    </style>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;position: absolute;width: 100%;height:100%">
<div id="popup" class="ol-popup">
    <a href="#" id="popup-closer" class="ol-popup-closer"></a>
    <div id="popup-content" data-i18n="resources.text_iClient9"></div>
</div>
<div id="map" style="width: 100%;height:100%"></div>
<script type="text/javascript" include="jquery" src="../js/include-web.js"></script>
<script type="text/javascript" include="mapv" src="../../dist/openlayers/include-openlayers.js"></script> v
<script type="text/javascript">
    var container = document.getElementById('popup');
    var content = document.getElementById('popup-content');
    var closer = document.getElementById('popup-closer');
    var overlay = new ol.Overlay(({
        element: container,
        autoPan: true,
        autoPanAnimation: {
            duration: 250
        }
    }));
    closer.onclick = function () {
        overlay.setPosition(undefined);
        closer.blur();
        return false;
    };
    var host = window.isLocal ? window.server : "http://support.supermap.com.cn:8090";
    var url = host + "/iserver/services/map-china400/rest/maps/ChinaDark";
    var map = new ol.Map({
        target: 'map',
        controls: ol.control.defaults({attributionOptions: {collapsed: false}})
            .extend([new ol.supermap.control.Logo()]),
        view: new ol.View({
            center: [113.28, 22.65],
            zoom: 8,
            projection: 'EPSG:4326'
        }),
        layers: [new ol.layer.Tile({
            source: new ol.source.TileSuperMapRest({
                url: url,
                prjCoordSys: {"epsgCode": 4326},
                attributions: new ol.Attribution({
                    html: "Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a>"
                }),
            }),
            projection: 'EPSG:4326'
        })]
    });
    map.addOverlay(overlay);
    $.get('../data/guang_dong.json', function (geojson) {
        var dataSet1 = mapv.geojson.getDataSet(geojson);
        var citys = {
            '深圳市': 20,
            '广州市': 40,
            '佛山市': 60,
            '江门市': 80,
            '中山市': 100,
        };
        var data1 = dataSet1.get({
            filter: function (item) {
                if (!citys[item.name]) {
                    return false;
                }

                item.count = citys[item.name];
                return true;
            }
        });
        dataSet1 = new mapv.DataSet(data1);
        var options = {
            gradient: {
                0: 'yellow',
                1: 'red'
            },
            globalAlpha: 0.8,
            draw: 'intensity'
        };

        var dataAttr = resources.text_dataSources + "<a target='_blank' href='http://mapv.baidu.com/examples/geojson-guangdong.html'>MapV</a>";
        map.addLayer(new ol.layer.Image({
            source: new ol.source.Mapv({map: map, dataSet: dataSet1, mapvOptions: options, attributions: dataAttr})
        }));

        var data2 = [];
        for (var key in citys) {
            var center = mapv.utilCityCenter.getCenterByCityName(key.replace('市', ''));
            data2.push(
                {
                    geometry: {
                        type: 'Point',
                        coordinates: [center.lng, center.lat],
                    },
                    text: key
                }
            );
        }
        var dataSet2 = new mapv.DataSet(data2);
        var textOptions = {
            draw: 'text',
            font: '14px Arial',
            fillStyle: 'blue',
            shadowColor: 'white',
            shadowBlue: 20,
            zIndex: 11,
            shadowBlur: 10
        };
        map.addLayer(new ol.layer.Image({
            source: new ol.source.Mapv({map: map, dataSet: dataSet2, mapvOptions: textOptions})
        }));
        setTimeout(function () {
            content.text = resources.text_iClient9;
            overlay.setPosition(map.getView().getCenter());
        }, 1000)
    });

</script>
</body>
</html>
